package com.qs.rocketmq.nacos.controller;

import com.qs.rocketmq.nacos.service.RegisterClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "/consumer")
public class NacosConsumerController {

    @Resource
    private RegisterClient registerClient;

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping(value = "/getConfig/{id}")
    public String getConfig(@PathVariable(name = "id") String id){
        return registerClient.getNacosDemoInfo(id);
    }

    @GetMapping(value = "/testRest/{id}")
    public String testRest(@PathVariable(name = "id") String id){
        String url = "http://nacos-demo//nacos/getConfig/" + id;
        return restTemplate.getForObject(url, String.class);
    }

}
